package com.twu.biblioteca.ui;

import com.twu.biblioteca.data.BookDAO;

/**
 * Created by florian on 26/12/13.
 */
public class MainScreenController implements ScreenController {
    private final ScreenControllerFactory screenControllerFactory;
    private final BibliotecaUI ui;
    private final BookDAO bookDAO;

    public MainScreenController(ScreenControllerFactory screenControllerFactory,BibliotecaUI ui,BookDAO bookDAO) {
        this.screenControllerFactory = screenControllerFactory;
        this.ui = ui;
        this.bookDAO = bookDAO; 
    }

    @Override
    public ScreenController processCommand(String line) {
        if (line.equals("q")) {
            return null;
        }else if (line.equals("1")) {
            ui.listBooks(bookDAO.getAllAvailableBooks());
            return this;
        }else if (line.equals("2")) {
            return screenControllerFactory.createCheckoutScreenController();
        } else if (line.equals("3")){
            return screenControllerFactory.createReturnBooksController();
        } else {
            ui.showInvalidMenuOptionMessage();
            return this;
        }
    }
}
